using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using Spike_EBC_Designer.ViewModel;

namespace Spike_EBC_Designer
{
    public abstract class PropertyBag
    {
        public abstract void Apply(ModelElement elem);
    }

    [DefaultPropertyAttribute("Label")]
    public class GridProperties : PropertyBag
    {
        [CategoryAttribute("Required"), DescriptionAttribute("Name der Platine")]
        public string Label { get; set; }
        [DescriptionAttribute("Welches Interface implementiert die Platine?")]
        public string Implements { get; set; }
        [DescriptionAttribute("Namespaces durch Komma getrennt, die die Platine importieren soll")]
        public string Usings { get; set; }

        public override void Apply(ModelElement elem)
        {
            var grid = (Grid)elem;
            grid.Label = this.Label;
            grid.Implements = this.Implements;
            grid.Usings = this.Usings;
        }
    }


    [DefaultPropertyAttribute("Label")]
    public class CellProperties : PropertyBag
    {
        [CategoryAttribute("Required"), DescriptionAttribute("Name der Funktionseinheit")]
        public string Label { get; set; }

        public override void Apply(ModelElement elem)
        {
            var cell = (Cell)elem;
            cell.Label = this.Label;
        }
    }


    [DefaultProperty("Typename")]
    public class RelationProperties : PropertyBag
    {
        [CategoryAttribute("Pins"), DescriptionAttribute("Name des Output-Pins")]
        public string OutputPinName { get; set; }
        [CategoryAttribute("Pins"), DescriptionAttribute("Name des Input-Pins")]
        public string InputPinName { get; set; }

        [CategoryAttribute("Required"), DescriptionAttribute("Typ des Drahtes zw. den Funktionseinheiten")]
        public string Typename { get; set; }


        public override void Apply(ModelElement elem)
        {
            var rel = (Relation)elem;
            rel.OutputPinName = this.OutputPinName;
            rel.InputPinName = this.InputPinName;
            rel.Typename = this.Typename;
        }
    }
}